package me.landery.modules.sinco.domain;

import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import me.landery.base.BaseEntity;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Objects;

/**
 * @Author cc.w
 * @Date 2022/6/7 17:18
 * @Version 1.0
 */
@Entity
@Getter
@Setter
@Table(name="sinco_mode")
public class Mode extends BaseEntity implements Serializable {
    @Id
    @Column(name = "pid", nullable = false)
    @NotNull(groups = BaseEntity.Update.class)
    @ApiModelProperty(value = "套餐ID", hidden = true)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(name = "mode_name")
    @NotBlank
    @ApiModelProperty(value = "套餐名")
    private String name;

    @Column(name = "mode_desc")
    @NotBlank
    @ApiModelProperty(value = "套餐描述")
    private String desc;

    @ApiModelProperty(value = "套餐描述")
    private Long quota; //额度

    @ApiModelProperty(value = "使用价格")
    private Double tax;

    @ApiModelProperty(value = "套餐价格")
    private Double price;

    @Column(name = "expire_day")
    @ApiModelProperty(value = "套餐有效天数")
    private Integer day; //有效天数

    @ApiModelProperty(value = "套餐折扣")
    private Double discount;

    @ApiModelProperty(value = "是否打折，0不打折，1百分比，2券")
    private Integer isdiscount;

    @ApiModelProperty(value = "排序字段")
    private Long asort;
    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Mode mode = (Mode) o;
        return Objects.equals(id, mode.id) &&
                Objects.equals(name, mode.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name);
    }

}
